/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.uoc.tdp.pac3.persistence.dao;

import java.sql.Date;
import edu.uoc.tdp.pac3.domain.RequestNote;
import java.util.List;
import edu.uoc.tdp.pac3.persistence.dao.impl.RequestNoteDao;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author Gerard
 */
public class RequestNoteDaoTestCase {

    private static IRequestNoteDao dao;

    @BeforeClass
    public static void setUpClass() throws Exception {
        dao = new RequestNoteDao();
    }

    @Test
    @Ignore
    public void test_insert() {
        RequestNote request = new RequestNote();
        request.setCreationDate(new Date(2011, 1, 1));
        request.setDescription("JUNIT");
        request.setUserId(1);
        request.setRequestId(1);
        request.setUserId(1);
        assertTrue(dao.insert(request));
    }

    @Test
    public void test_update() {
        RequestNote request = dao.findById(2);
        request.setDescription("DESC_JUNIT");
        assertTrue(dao.update(request));
    }

    @Test
    public void test_retrieve_data() {
        List<RequestNote> list = dao.findAll();
        assertEquals(1, list.size());
    }
    
    @Test
    public void test_retrieve_data_selected_request() {
        List<RequestNote> list = dao.getRequestNotes(1);
        assertEquals(1, list.size());
    }
    

    @Test
    public void test_findById() {
        RequestNote request = dao.findById(1);
        assertNotNull(request);
    }

    @Test
    public void test_delete() {
        RequestNote area = dao.findById(1);
        assertNotNull(area);
        Boolean result = dao.delete(area);
        assertTrue(result);
    }
}
